#pragma warning(disable:4786)
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Complex
{
	int real,img;
public:
	Complex()
	{
		real = img =0;
	}
	Complex(int r,int i)
	{
		real =r;
		img =i;
	}
	Complex& operator +=(Complex &a)
	{
		real += a.real;
		img += a.img;
		return *this;
	}
	void Display()
	{
		cout<<"Real:  "<<real<<"  Img:  "<<img<<endl;
	}
};
template <class C>typename C::iterator find_last(C&c,typename C::value_type v)
{
	typename C::reverse_iterator ri = find(c.rbegin(),c.rend(),v);
	if(ri == c.rend()) return c.end();
	typename C::iterator i = ri.base();
	return --i;
}
template <class C>typename C::value_type sum(const C&c)
{
	typename C::value_type s=0;
	typename C::const_iterator p = c.begin();
	while(p!=c.end())
	{
		s+= *p;
		++p;
	}
	return s;	
}
void main1()
{
	vector<int> v;
	for(int i=0;i<1000;i++)
		v.push_back(i);
	cout<<sum(v)<<endl;
	cout<<v.size()<<endl;;
	cout<<*find_last(v,200)<<endl;

}
